import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)
export const constantRoutes = [
  { path: '/', redirect: '/home' },
  {
    path: '/',
    name: 'app',
    component: () => import('@/views/layout/index'),
    // component: resolve => require(['@/views/layout/index'], resolve),
    meta: {
      keepAlive: false
    },
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index'),
      // component: resolve => require(['@/views/home/index'], resolve),
      meta: {
        keepAlive: false,
      }
    }, {
      path: 'me',
      name: 'me',
      component: () => import('@/views/me/index'),
      // component: resolve => require(['@/views/me/index'], resolve),
      meta: {
        keepAlive: false,
        title: '个人中心'
      }
    }]
  },
  {
    path: '/orderList',
    name: 'orderList',
    component: () => import(/* webpackChunkName: "orderList" */ '@/views/orderList/detail'),
    // component: resolve => require(['@/views/orderList/detail'], resolve),
    meta: {
      keepAlive: false,
      transition: true,
      title:'预约记录'
    }
  },
  {
    path: '/orderDetail',
    name: 'orderDetail',
    component: () => import(/* webpackChunkName: "orderDetail" */ '@/views/orderList/detail'),
    // component: resolve => require(['@/views/orderList/detail'], resolve),
    meta: {
      keepAlive: false,
      transition: true,
      title:'预约详情'
    }
  },
  {
    path: '/myFriend',
    name: 'myFriend',
    component: () => import(/* webpackChunkName: "myFriend" */ '@/views/myFriend/index'),
    // component: resolve => require(['@/views/myFriend/index'], resolve),
    meta: {
      keepAlive: false,
      title:'我的浆友'
    }
  },
  {
    path: '/myFriendDetail/:id',
    name: 'myFriendDetail',
    component: () => import(/* webpackChunkName: "myFriendDetail" */ '@/views/myFriend/detail'),
    // component: resolve => require(['@/views/myFriend/detail'], resolve),
    meta: {
      keepAlive: false,
      title:'详情'
    }
  },
  {
    path: '/recommend',
    name: 'recommend',
    component: () => import(/* webpackChunkName: "recommend" */ '@/views/recommend/index'),
    // component: resolve => require(['@/views/recommend/index'], resolve),
    meta: {
      keepAlive: false,
      title:'推荐详情'
    }
  },
  {
    path: '/invite',
    name: 'invite',
    component: () => import(/* webpackChunkName: "invite" */ '@/views/invite/index'),
    // component: resolve => require(['@/views/recommend/index'], resolve),
    meta: {
      keepAlive: false,
      title:'推荐详情'
    }
  },
  {
    path: '/articles',
    name: 'articles',
    component: () => import(/* webpackChunkName: "articles" */ '@/views/articles/index'),
    // component: resolve => require(['@/views/articles/index'], resolve),
    meta: {
      keepAlive: false,
      title:'资讯'
    }
  },
  {
    path: '/articleDetail/:id',
    name: 'articleDetail',
    component: () => import(/* webpackChunkName: "articleDetail" */ '@/views/articles/detail'),
    // component: resolve => require(['@/views/articles/detail'], resolve),
    meta: {
      keepAlive: false,
      title:'资讯详情'
    }
  },
  {
    path: '/notice',
    name: 'notice',
    component: () => import(/* webpackChunkName: "articles" */ '@/views/notice/index'),
    // component: resolve => require(['@/views/articles/index'], resolve),
    meta: {
      keepAlive: false,
      title:'消息通知'
    }
  },
  {
    path: '/noticeDetail/:id',
    name: 'noticeDetail',
    component: () => import(/* webpackChunkName: "articles" */ '@/views/notice/detail'),
    // component: resolve => require(['@/views/articles/index'], resolve),
    meta: {
      keepAlive: false,
      title:'消息详情'
    }
  },
  {
    path: '/donateList',
    name: 'donateList',
    component: () => import(/* webpackChunkName: "donateList" */ '@/views/donateList/index'),
    // component: resolve => require(['@/views/donateList/index'], resolve),
    meta: {
      keepAlive: false,
      title:'献浆记录'
    }
  },
  {
    path: '/userInfo',
    name: 'userInfo',
    component: () => import(/* webpackChunkName: "userInfo" */ '@/views/userInfo/index'),
    // component: resolve => require(['@/views/userInfo/index'], resolve),
    meta: {
      keepAlive: false,
      title:'基本信息'
    }
  },
  {
    path: '/collects',
    name: 'collects',
    component: () => import(/* webpackChunkName: "collects" */ '@/views/articles/collects'),
    // component: resolve => require(['@/views/articles/collects'], resolve),
    meta: {
      keepAlive: false,
      title:'收藏文章'
    }
  },
  {
    path: '/order',
    name: 'order',
    component: () => import(/* webpackChunkName: "order" */ '@/views/order/index'),
    // component: resolve => require(['@/views/order/index'], resolve),
    meta: {
      keepAlive: false,
      title:'个人预约'
    }
  },
  {
    path: '/income',
    name: 'income',
    component: () => import(/* webpackChunkName: "income" */ '@/views/income/index'),
    // component: resolve => require(['@/views/income/index'], resolve),

    meta: {
      keepAlive: false,
      title:'收益'
    }
  },
  {
    path: '/points',
    name: 'points',
    component: () => import(/* webpackChunkName: "points" */ '@/views/points/index'),
    // component: resolve => require(['@/views/income/index'], resolve),

    meta: {
      keepAlive: false,
      title:'积分'
    }
  },
  {
    path: '/rules',
    name: 'rules',
    component: () => import(/* webpackChunkName: "rules" */ '@/views/rules/index'),
    // component: resolve => require(['@/views/rules/index'], resolve),

    meta: {
      keepAlive: false,
      title:'积分规则'
    }
  },
  {
    path: '/test',
    name: 'test',
    component: () => import(/* webpackChunkName: "test" */ '@/views/test/index'),
    // component: resolve => require(['@/views/test/index'], resolve),

    meta: {
      keepAlive: false
    }
  },
  {
    path: '/betterScroll',
    name: 'test',
    component: () => import('@/views/test/betterScroll'),
    // component: resolve => require(['@/views/test/betterScroll'], resolve),

    meta: {
      keepAlive: false
    }
  }
]

const createRouter = () =>
  new Router({
    mode: 'history', // require service support
    // base: '/app/',
    scrollBehavior: () => ({
      y: 0
    }),
    routes: constantRoutes
  })

export default createRouter()
